<div class="yiiForm">

<?php $this->widget('application.components.RequiredMessage'); ?>

<?php echo CHtml::beginForm(); ?>

<?php echo CHtml::errorSummary($model); ?>

<div class="simple">
<?php echo CHtml::activeLabelEx($model,'first_name'); ?>
<?php echo CHtml::activeTextField($model,'first_name',array('size'=>60,'maxlength'=>100)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'last_name'); ?>
<?php echo CHtml::activeTextField($model,'last_name',array('size'=>60,'maxlength'=>100)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'gender'); ?>
<table border="0" cellspacing="0" cellpadding="0" width="50%">
<tr>
	<td>
		<?php echo CHtml::activeRadioButtonList($model,'gender',Constants::genders(), array('separator' => "</td><td>")); ?>
	</td>
</tr>
</table>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'birth_date'); ?>
<?php
if ($model->birth_date != null && $model->birth_date != "")
{
	$date = Constants::fromSqlDate($model->birth_date);
	$model->birth_date = $date;
}else{
	$date = date(Constants::SQL_DATE_FORMAT	, mktime(date("H"), date("i"), date("s"), date("n"), date("j"), ((int)date("Y"))-20));
	
	//Constants::print_var($date);
}
/*
echo CHtml::activeTextField($model, 'birth_date');
$p = 'birth_date';
$options = array ();
CHtml::resolveNameID($model, $p, $options);
$this->widget('application.extensions.calendar.SCalendar', array (
	'inputField' => $options['id'],
	'dateFormat' => '%d/%m/%Y',
	'date' => $date
));*/
	$this->widget('zii.widgets.jui.CJuiDatePicker', array (
		//'id'=>'param_value_'.$i,
		'model' => $model,
		'attribute' => "birth_date",
		// additional javascript options for the date picker plugin
		'options' => Constants::$JuiDatePickerOptions
	));
?> (dd/mm/yyyy)
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'address1'); ?>
<?php echo CHtml::activeTextField($model,'address1',array('size'=>60,'maxlength'=>255)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'address2'); ?>
<?php echo CHtml::activeTextField($model,'address2',array('size'=>60,'maxlength'=>255)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'address3'); ?>
<?php echo CHtml::activeTextField($model,'address3',array('size'=>60,'maxlength'=>255)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'city_id'); ?>
<?php


$p = 'city_id';
$options = array ();
CHtml::resolveNameID($model, $p, $options);

$this->widget('CAutoComplete', array (
	//name of the html field that will be generated
	'name' => 'city_id',
	//replace controller/action with real ids
	'url' => array (
		'project/findCity'
	),
	'max' => 10, //specifies the max number of items to display

	//specifies the number of chars that must be entered 
	//before autocomplete initiates a lookup
	'minChars' => 2,
	'delay' => 500, //number of milliseconds before lookup occurs
	'matchCase' => false, //match case when performing a lookup?

	//any additional html attributes that go inside of 
	//the input field can be defined here
	'htmlOptions' => array (
		'size' => '40'
	),

	'methodChain' => ".result(function(event,item){\$(\"#" . $options['id'] . "\").val(item[1]);})",

	
));

echo CHtml::activeHiddenField($model, $p);

//echo CHtml::activeTextField($model,'city_id'); 
?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'phone_number'); ?>
<?php echo CHtml::activeTextField($model,'phone_number',array('size'=>60,'maxlength'=>255)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'email'); ?>
<?php echo CHtml::activeTextField($model,'email',array('size'=>60,'maxlength'=>255)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'referent'); ?>
<?php echo CHtml::activeTextField($model,'referent',array('size'=>60,'maxlength'=>255)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'service_id'); ?>
<?php echo CHtml::activeDropDownList($model,'service_id', CHtml::listData(Service::model()->findAll(), 'id', 'label'), array('style' => 'width:250px;')); ?>
</div>

<?php

$specificData = Yii::app()->parameter->getParametersArray('OWNER_SPEC');

foreach ($model->specificData as $id=>$specificDatum) {
	$name = 'specificData['.$id.']';
	$name = CHtml::resolveName($model,$name);
?>
<div class="simple">
<?php echo CHtml::label($specificData[$id]['FLDLBL'], $name, array('id'=>$name)); ?>
<?php echo CHtml::tag('input',array('size'=>60,'maxlength'=>255, 'name'=>$name, 'value'=>$specificDatum, 'id' => $name)); ?>
</div>

<?php 	
}


echo CHtml::activeHiddenField($model,'adviser_initials');
echo CHtml::activeHiddenField($model, 'owner_id');

$this->printHiddenField($model);


?>

<div class="action">
<?php echo CHtml::submitButton(Yii::t('views', 'Next >')); ?>
</div>

<?php echo CHtml::endForm(); ?>

</div><!-- yiiForm -->